from django.contrib import admin
from .models import Notification, UserPreference


@admin.register(Notification)
class NotificationAdmin(admin.ModelAdmin):
    """系统通知管理"""
    list_display = ['id', 'user', 'notification_type', 'title', 'is_read', 'priority', 'created_at']
    list_filter = ['notification_type', 'is_read', 'priority', 'created_at']
    search_fields = ['user__username', 'title', 'content']
    date_hierarchy = 'created_at'
    ordering = ['-priority', '-created_at']


@admin.register(UserPreference)
class UserPreferenceAdmin(admin.ModelAdmin):
    """通知偏好设置管理"""
    list_display = ['id', 'user', 'enable_system', 'enable_emotion', 'enable_course', 'enable_community', 'enable_crisis', 'enable_activity']
    list_filter = ['enable_system', 'enable_emotion', 'enable_course', 'enable_community', 'enable_crisis', 'enable_activity']
    search_fields = ['user__username']
    ordering = ['-updated_at']
